package cn.com.dhcc.app.pub.core.job.remove;

import org.apache.log4j.Logger;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import cn.com.dhcc.app.core.CM;
import cn.com.dhcc.app.core.AppEnv.ParaGetTool;
import cn.com.dhcc.app.core.base.IocBean;
import cn.com.dhcc.app.core.exception.ServiceException;
import cn.com.dhcc.app.core.service.Log;
import cn.com.dhcc.app.core.service.Log.LOGTYPE;
import cn.com.dhcc.turbo.entity.registry.NodeInfo;
import cn.com.dhcc.turbo.service.monitor.MonitorService;
import cn.com.dhcc.turbo.service.registry.BaseInfoService;

/**
 * 定时删除已处理告警历史
 * 
 * @日期：2014-7-29 上午9:18:27
 * @作者：张洪涛
 * @版权所有：东华软件
 * @版本：1.0
 */
public class QuotaValueOnTimeCronJob extends QuartzJobBean {
	@SuppressWarnings("deprecation")
	Logger logger = Log.getExistLogger(LOGTYPE.TURBO);

	@Override
	protected void executeInternal(JobExecutionContext context)
			throws JobExecutionException {
		BaseInfoService baseInfoService=(BaseInfoService) CM.getBeanByName(IocBean.BASE_INFO_SERVICEIMPL_BEAN);
		NodeInfo localNode;
		try {
			localNode = baseInfoService.getCurrentNodeInfo();
			if (localNode==null) {
				return;
			}
		} catch (ServiceException e) {
			logger.error("获取本节点信息失败:"+e);
		}
		MonitorService service = CM.getBean(MonitorService.class);
		String day = ParaGetTool.getPara("job.remove.alert.day");//获取时间配置参数
		try {
			service.timingDelete(day);
		} catch (ServiceException e) {
			logger.error(e);
		}

	}

}
